package edu.jmu.action.message;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import edu.jmu.action.BaseAction;
import edu.jmu.bean.message.MessageToUser;
import edu.jmu.service.message.MessageToUserService;
import edu.jmu.utils.WebUtil;
/***
 * 
 * @author Geven7
 *
 */
@Controller 
@ParentPackage("json-default")
@Result(type="json")
@Namespace("/jsonMessageManage")
@Scope(value="prototype")
public class MessageUnreadCountAction extends BaseAction<MessageToUser> {
	private static final long serialVersionUID = -735086234456854931L;
	@Resource
	private MessageToUserService messageToUserService;
	private int messageUnreadCount;
	
	@Action(value="messageUnreadCount",results=@Result(type="json"))
	public String messageToUserUnreadCountByToUser(){
		messageUnreadCount = (int) messageToUserService.GetMessageToUserUnreadCountByToUserName(WebUtil.getUser());
		return SUCCESS;
	}

	public int getMessageUnreadCount() {
		return messageUnreadCount;
	}
}
